<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>全选/全不选</title>
</head>
<body>
	<input type="checkbox" name="a" value="a" class="fuxuankuang">a
	<input type="checkbox" name="b" value="b" class="fuxuankuang">b
	<input type="checkbox" name="c" value="c" class="fuxuankuang">c
	<input type="button" onclick="quanxuan()" value="全选">
	<input type="button" onclick="quanbuxuan()" value="全不选">
	<input type="button" onclick="fanxuan()" value="反选">
</body>
	<script type="text/javascript">
		
			function quanxuan(){
				var fuxuankuang = document.getElementsByClassName("fuxuankuang")
				for (var i = 0; i < fuxuankuang.length; i++) {
					fuxuankuang[i].checked = true
				}
			}
			function quanbuxuan(){
				var fuxuankuang = document.getElementsByClassName("fuxuankuang")
				for (var i = 0; i < fuxuankuang.length; i++) {
					fuxuankuang[i].checked = false
				}
			}
			function fanxuan(){
				var fuxuankuang = document.getElementsByClassName("fuxuankuang")
				for (var i = 0; i < fuxuankuang.length; i++) {
					if(fuxuankuang[i].checked == true){
						fuxuankuang[i].checked = false
					}else{
						fuxuankuang[i].checked = true
					}
				}
			}		
	</script>
</html>